(function($){
	$(function(){
		
		$.ajax({
			type:"get",
			url:"http://datainfo.duapp.com/shopdata/getclass.php",
			dataType:"json",
			success:function(data){
				
				var lhtml = "";
				$.each(data,function(index){
					
					if(index !=2 && index !=11 && index !=12){
						lhtml+='<li classId='+data[index].classID+'><i class="iconfont list_icon">'+data[index].icon+'</i><span class="list_span">'+data[index].className+'</span></li>'
					}
				})
				$(".list_icon").html(lhtml);
				$(".list_icon li").eq(0).addClass("shop_active")
				/////////////////////////点击小图标
				$(".list_icon li").click(function(){
					var inde = $(".list_icon li").index(this);
					var claid = $(".list_icon li").eq(inde).attr("classId");
					$(".list_icon li").removeClass("shop_active").eq(inde).addClass("shop_active");
					getGoods(claid,0);	
				})
			}
					
		});
		
		getGoods(1,0);
		
		
		
		
		function getGoods(classID,pageCode){
			
			$.ajax({
			type:"get",
			url:"http://datainfo.duapp.com/shopdata/getGoods.php",
			data:{classID:classID,pageCode:pageCode},
			dataType:"jsonp",
			success:function(data){
//				console.log(data);
				var xhtml = "";
				$.each(data,function(index){
					xhtml+='<dl>'
					xhtml+='<dt goodsID='+data[index].goodsID+' class="shops_dt"><img src="'+data[index].goodsListImg+'" class="goods"/><span class="jixian"></span></dt>'
					xhtml+='<dd>'
					xhtml+='<h3>'+data[index].goodsName+'</h3>'
					xhtml+='<p>￥<span>'+data[index].price+'</span><b>￥999</b></p>'
					xhtml+='</dd>'
					xhtml+='</dl>'
				})
				
				$(".shops").html(xhtml);
				$('.shops .shops_dt').on("touchend",function(){
					var dtindex = $('.shops .shops_dt').index(this);
					var goodsId = $('.shops .shops_dt').eq(dtindex).attr("goodsID");
					localStorage.setItem("goodsId",goodsId);
					window.open("ziliao.html","_self")
				})
					
			}		
		});
		}
	////////////////////////////购物车
	var num =0;
	var usename = localStorage.getItem("name");
	$.ajax({
	  type: "get",
	   url: "http://datainfo.duapp.com/shopdata/getCar.php",
	   data: {userID:usename},
	   dataType:"jsonp",
	   success:function(data){
	   	$.each(data, function(index){
	     	num+=parseInt(data[index].number);
	   	})
	   	
	   	if(num<=0){
			$(".car_num").css("display","none");
			$(".car_num1").css("display","none");
		}else{
			$(".car_num").css("display","block").html(num);
			$(".car_num1").css("display","block").html(num);
		}
	   }
	});
	
	
	
	///////////////////////////底部不同设备的点击
	$(".foo").click(function(){
		var foinde = $(".foo").index(this);
		$(".foo").removeClass("bt").eq(foinde).addClass("bt");
	})
	////////////////////////////////
	$(".fenlei").on("touchend",function(){
		window.open("shoplist.html","_self");
	})
	////////////////////////////////
	$(".gouwuche").on("touchend",function(){
		window.open("gouwuche.html","_self");
	})
	/////////////////////////////////////
	$(".wodexiu").on("touchend",function(){
		window.open("wdxiu.html","_self")
	})
	//////////////////////////////
	$(".genduo").on("touchend",function(){
		window.open("chouj.html","_self")
	})
	
	
	
})	
})(jQuery)

//////////////